package com.ruoyi.womp.ws;

import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebServiceConfig {

	@Autowired
	private DeviceRegWebService deviceRegWebService;

	@Bean(name = "cxfServlet")
	public ServletRegistrationBean<CXFServlet> cxfServlet() {
		return new ServletRegistrationBean<CXFServlet>(new CXFServlet(), "/webservice/*");
	}

	@Bean(name = Bus.DEFAULT_BUS_ID)
	public SpringBus springBus() {
		return new SpringBus();
	}

	/**
	 * 注册deviceRegWebService接口到webservice服务
	 * 
	 * @return
	 */
	@Bean(name = "DeviceRegWebServiceEndpoint")
	public Endpoint sweptPayEndpoint() {
		EndpointImpl endpoint = new EndpointImpl(springBus(), deviceRegWebService);
		endpoint.publish("/deviceReg");
		return endpoint;
	}

}